package thread;

import java.util.concurrent.*;

/**
 * User: Administrator
 * Date: 2020/12/8
 * Time: 16:22
 * Description:
 */
public class InterrupteDemo {

    private static ThreadPoolExecutor pool = new ThreadPoolExecutor(8, 20, 0, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(1));

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i<100; i++) {
            System.out.println(pool.toString());
            if (pool.getActiveCount() < 20) {
                pool.execute(new ThreadDemo());
            } else{
                Thread.sleep(5000);
            }
        }
        /*Thread.sleep(3000);
        System.out.println(pool.getActiveCount());
        System.out.println(pool.getCompletedTaskCount());
        BlockingQueue<Runnable> queue = pool.getQueue();
        System.out.println(queue.size());
        System.out.println(pool.getLargestPoolSize());
        System.out.println(pool.getTaskCount());*/
    }
}
